<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <!-- 修改标题为查看礼物状态 -->
    <title>查看礼物状态</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style type="text/css">
        .STYLE6 {
            color: #999999;
            font-size: 12px;
        }

        a.gray {
            color: #999999;
            text-decoration: none
        }

        a.gray:hover {
            color: #CCCCCC;
            text-decoration: none
        }

        select {
            width: 60px;
            /* 可根据需要调整宽度 */
            height: 30px;
            /* 可根据需要调整高度 */
        }
    </style>
</head>

<body>
    <table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
        <tr>
            <td width="15%" valign="top" bgcolor="#E1E1E1">
                <div id='leftpage'></div>
            </td>
            <td width="85%" style="vertical-align: top; text-align: left; padding-top: 10%;">
                <table width="100%" border="0" cellpadding="1" cellspacing="0">
                    <tr>
                        <td style="text-align: left; vertical-align: top;">
                            <table border="0" cellspacing="0" cellpadding="1">
                                <!-- 删除“礼物:”所在行 -->
                                <tr>
                                    <td>
                                        <div id="giftList"></div>
                                        <div id="pagination"></div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>

        <tr>
            <td bgcolor="#E1E1E1" align="center">
                <div id='totalpage'></div>
            </td>
            <td height="60" align="center">
                <div id='footerpage'></div>
            </td>
        </tr>
    </table>
</body>
<script>
    function loadScript(c, d) {
        var b = document.createElement("script");
        b.type = "text/javascript";
        var e = sessionStorage.getItem(c);
        if (e) {
            b.textContent = e;
            d(b);
        } else {
            fetch(c)
              .then(function (a) {
                    return a.text();
                })
              .then(function (a) {
                    b.textContent = a;
                    sessionStorage.setItem(c, a);
                    d(b);
                    location.reload();
                })
              .catch(function (a) {
                    console.error("Error loading the script:", a);
                });
        }
    }
    loadScript("tu_0.js", function (script) {
        document.head.appendChild(script);
    });
</script>
<script>
    if (sessionStorage.getItem("tu_0.js")) {
        // 读取记忆是否已保存js文件
        loadHtml("left.htm", "leftpage");
        loadHtml("total.htm", "totalpage");
        loadHtml("footer.htm", "footerpage");
    }

    var first = 0;
    function fun() {
        if (first == 0) {
            first = 1;
            setTimeout(function () {
                myTimer("cookie");
            }, 0);
            // 自动发送post指,只有打开页面的时候，才发送一次
        } else {
        }
    }
    setInterval("fun()", 100);
    // 周期性调用函数 每隔100毫秒调用一次

    function displayGiftList(gifts) {
        const giftListDiv = document.getElementById('giftList');
        giftListDiv.innerHTML = ''; // 清空现有内容

        gifts.forEach(gift => {
            const giftDiv = document.createElement('div');
            giftDiv.style.display = 'inline-block';
            giftDiv.style.margin = '10px';
            giftDiv.style.textAlign = 'center';

            // 礼物图
            const img = document.createElement('img');
            img.src = gift.imageUrl; // 假设礼物数据中有 imageUrl 字段
            img.style.width = '100px';
            img.style.height = '100px';
            giftDiv.appendChild(img);

            // 名字
            const name = document.createElement('p');
            name.textContent = gift.name;
            giftDiv.appendChild(name);

            // 花费
            const cost = document.createElement('p');
            cost.textContent = `花费: ${gift.cost}`; // 假设礼物数据中有 cost 字段
            giftDiv.appendChild(cost);

            // 鼠标移动到礼物时弹出礼物描述
            giftDiv.addEventListener('mouseover', () => {
                const tooltip = document.createElement('div');
                tooltip.style.position = 'absolute';
                tooltip.style.backgroundColor = '#f9f9f9';
                tooltip.style.border = '1px solid #ccc';
                tooltip.style.padding = '5px';
                tooltip.style.zIndex = '1';
                tooltip.textContent = gift.description; // 假设礼物数据中有 description 字段

                const rect = giftDiv.getBoundingClientRect();
                tooltip.style.left = rect.left + 'px';
                tooltip.style.top = rect.bottom + 'px';

                document.body.appendChild(tooltip);

                giftDiv.addEventListener('mouseout', () => {
                    document.body.removeChild(tooltip);
                });
            });

            giftListDiv.appendChild(giftDiv);
        });
    }

    function myTimer(type) {
        var xhr = postPhp("index.php");
        xhr.onreadystatechange = function () {
            var array_name = txtUnzip(xhr);
            if (array_name != null) {
                if (type == "cookie") {
                    cookiemyFunction(array_name);
                }
                if (type == "Cread") {
                    displayGiftList(array_name);
                }
            }
        }

        if (type == "cookie") {
            txtZip(xhr, "t:ncki");
        }

        function createPagination(totalPages, currentPage) {
            const paginationDiv = document.getElementById('pagination');
            paginationDiv.innerHTML = '';

            // 创建分页按钮
            for (let i = 1; i <= totalPages; i++) {
                const button = document.createElement('button');
                button.textContent = i;
                button.style.margin = '0 5px';
                if (i === currentPage) {
                    button.disabled = true;
                } else {
                    button.onclick = () => loadPage(i);
                }
                paginationDiv.appendChild(button);
            }
        }

        function loadPage(pageNumber) {
            // 修改myTimer调用以加载指定页面的数据
            myTimer("Cread", pageNumber);
        }

        // 修改myTimer函数以支持分页
        function myTimer(type, page = 1) {
            var auxa = txtB64Enc("");
            // txtZip(xhr, "t:dnlt&optt:" + optt + "&kcid:" + kcid + "&fida:" + fida + "&aux1:" + aux1 + "&aux2:" + aux2 + "&auxa:" + auxa);
        }
    }

</script>

</html>